<?php

Yii::import('application.models._base.BaseSectionRecommend');

class SectionRecommend extends BaseSectionRecommend
{
	public static function model($className=__CLASS__) {
		return parent::model($className);
	}
    public function createData($section_code,$tbl_name,$tbl_id,$exceed_time){
        $db = new SectionRecommend();
        $db->section_code = $section_code;
        $db->tbl_name = $tbl_name;
        $db->tbl_id = $tbl_id;
        $db->status = 1;
        $db->exceed_time = $exceed_time;
        $db->create_time = time();
        $info = $db->save();
        return $info;
    }
    public function getAllData($section_code,$num){
        $db = Yii::app()->db->createCommand();
        $time = time();
        $info = $db
            ->select('tbl_name,tbl_id')
            ->from('{{section_recommend}}')
            ->where('section_code=:section_code and exceed_time >:exceed and status=:status',array(':section_code'=>$section_code,':exceed'=>$time,':status'=>1))
            ->order('create_time desc')
            ->limit($num)
            ->queryAll();
        return $info;
    }


}